<?php

/*
 *  Username: ________________________
 *  Password: ________________________
 *  User type: [Admin/FHManager/FD]
 *  User Status: [ACTIVE/SUSPEND/PENDING]
 *
 *  Notes:
 *  +---------------------------------------+
 *  |                                       |
 *  |                                       |
 *  |                                       |
 *  |                                       |
 *  +---------------------------------------+
 *
 *  [Back] [Go]
 */

class UserAccountForm extends Zend_Form
{
    private $picture_path = "";

    public function __construct($options=array())
    {
        parent::__construct($options);

        // set form name and POST
        $this->setName('user_account');
        $this->setMethod('post');
        $this->setEnctype('multipart/form-data');

        // create basic field decorators
        $basicDecorators = array(
            'ViewHelper',
            array('Errors', array('placement'=>'prepend')),
            array(array('labelBr'=>'HtmlTag'), array('tag'=>'br')),
            array('Label', array('placement'=>'prepend')),
            array( array('outerDiv'=>'HtmlTag'), array('tag'=>'div', 'style'=>'margin-top:5px')),
        );

        $username = new Zend_Form_Element_Text('username', array('size'=>20, 'label'=>'Username', 'required'=>true));
		$username->setDecorators($basicDecorators);
		
        $password = new Zend_Form_Element_Text( 'password', array('size'=>20, 'label'=>'Password', 'required'=>true));
		$password->setDecorators($basicDecorators);

		$notes = new Zend_Form_Element_Textarea( 'notes', array('rows'=>5, 'cols'=>60));
		$notes->setDecorators($basicDecorators);

        // form's submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Submit');

		$form_elements = array( $username, $password, $submit );
		
        $this->addElements( $form_elements );
    }

    // dirt-simple template engine.
    public function render_with_template( $template_name )
    {
        $template_file_path = APP_DIR."/views/templates/$template_name";
        $template_contents = file_get_contents( $template_file_path );

        // str_replace() keywords, adding errors where needed
        $form_elements = $this->getElements();

        $template_contents = str_replace( "{USERNAME}", $form_elements['username'], $template_contents );
        $template_contents = str_replace( "{USERNAME}", $form_elements['password'], $template_contents );
        $template_contents = str_replace( "{SUBMIT_BUTTON}", $form_elements['submit'], $template_contents );

        echo $template_contents;
    }
}

?>
